package net.chenlin.dp.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.chenlin.dp.modules.business.dao.TcpDataMapper;
import net.chenlin.dp.modules.business.entity.DataExportVo;
import net.chenlin.dp.modules.business.entity.vo.tcp.TcpDataList;
import net.chenlin.dp.modules.utils.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author Yangsm
 * @ClassName: DataExportController
 * @Description: TODO
 * @date 2023年08月02日 17:05
 */
@RestController
@RequestMapping("/export")
@Api(tags = "数据导出")
public class DataExportController {

    @Autowired
    private TcpDataMapper tcpDataMapper;

    @ApiOperation(value = "96个点位的数据导出功能")
    @GetMapping("/data")
    public void getShareholdingInfo(HttpServletResponse response, HttpServletRequest request,
                                    @RequestParam(value = "deviceNo",required = true) String deviceNo,
                                    @RequestParam(value = "dateTime",required = true) String dateTime) {

        List<DataExportVo> list = tcpDataMapper.getExportData(deviceNo,dateTime);

        ExcelUtil.writeExcel(response,request, list, "点位数据信息.xlsx", "数据详情", DataExportVo.class);
    }

}
